﻿using CodeSaude.Domain.Interfaces.Repository;
using CodeSaude.Domain.Interfaces.Service;
using System;
using System.Collections.Generic;
using System.Linq.Expressions;

namespace CodeSaude.Domain.Services
{
    public class BaseService <TEntity> : IDisposable, IBaseService<TEntity> where TEntity : class
    {
        private readonly IBaseRepository<TEntity> _repository; 

        public BaseService(IBaseRepository<TEntity> repository)
        {
            _repository = repository;

        }

        public virtual void Add(TEntity obj)
        {
            _repository.Add(obj);
        }

        public virtual TEntity GetById(int id)
        {
           return _repository.GetById(id);
        }

        public virtual IEnumerable<TEntity> GetAll()
        {
            return _repository.GetAll();
        }

        public virtual IEnumerable<TEntity> GetAllReadOnly()
        {
            return _repository.GetAllReadOnly();
        }

        public virtual void Update(TEntity obj)
        {
            _repository.Update(obj);
        }

        public virtual void Remove(TEntity obj)
        {
            _repository.Remove(obj);
        }

        public void Dispose()
        {
            _repository.Dispose();
        }

        public IEnumerable<TEntity> FindReadOnly(Expression<Func<TEntity, bool>> predicate)
        {
            return _repository.FindReadOnly(predicate);
        }

        //public IEnumerable<TEntity> Find(Expression<Func<TEntity, bool>> predicate)
        //{
        //    return _repository.Find(predicate);
        //}

        //public IEnumerable<TEntity> FindNoProxy(Expression<Func<TEntity, bool>> where, string[] includes = null)
        //{
        //    return _repository.FindNoProxy(where, includes);
        //}

        //public List<TEntity> Get(Expression<Func<TEntity, bool>> predicate, string[] includes = null)
        //{
        //    return _repository.Get(predicate, includes);
        //}

    }
}
